<?php
require 'connect.php';
if (isset($_POST['name']) || isset($_POST['submit'])) {
	$username = @$_POST['name'];
} else {
	exit('非法操作');
}
$query = "select * from user where username='$username'";
$result = mysql_query($query);

if (mysql_fetch_array($result)) {
	echo true;
} else {
	echo false;
}
if (isset($_POST['submit']) && $_POST['submit'] == '注册') {
	$username = $_POST['username'];
	$password = md5($_POST['pw']);
	$email = $_POST['email'];
	$query = "insert into user values(null,'$username','$password','$email')";
	mysql_query($query);
	header('location:../html/login.html');
}
mysql_close();
?>